home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Adjust.ieb 1.2, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 19/1 1997 Stockholm/Sweden ** ** Adjust slices of image vertically or horizontally. ** Based on the script Adjust.rexx 1.2. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' ADJ_H=20; SLICE_H=16; ADJ_V=20; SLICE_V=16 if command ~= '' then parse var command '#'ADJTYPE ADJ_H SLICE_H ADJ_V SLICE_V . 'IE_TO_FRONT' form = 'FORM "Adjust" " Accept | Cancel "', ' TEXT,"Adjust cuts the image into slices which are adjusted horizontally or vertically"' if command = '' then form = form ||' RADIO,"Adjustment","Horizontally (Up & Down)|Vertically (Left & Right)|Both (First Horiz. then Vert.)|Both (First Vert. then Horiz.)",0' form = form ||' INTEGER,"Slice adjustment (Horiz)",1,1024,'strip(ADJ_H)',SLIDER', ' INTEGER,"Slice width (Horiz)",1,1024,'strip(SLICE_H)',SLIDER', ' INTEGER,"Slice adjustment (Vert)",1,1024,'strip(ADJ_V)',SLIDER', ' INTEGER,"Slice width (Vert)",1,1024,'strip(SLICE_V)',SLIDER' form if command = '' then parse var result ok ADJTYPE ADJ_H SLICE_H ADJ_V SLICE_V . else do parse var result ok ADJ_H SLICE_H ADJ_V SLICE_V . ADJTYPE = 'none' end if ok = 0 then return '<ERROR>' back = '#'ADJTYPE ADJ_H SLICE_H ADJ_V SLICE_V return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' parse var options '#'ADJTYPE ADJ_H SLICE_H ADJ_V SLICE_V . 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'PROJECT_INFO' LoadImage 'WIDTH' IW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' IH = RESULT 'BRIGHTNESS' LoadImage '-255' 'INTENSITY' /* Black image */ AdjImage = Result OrgImage = LoadImage UoD = -1 if ADJTYPE=0 then call horiz() if ADJTYPE=1 then call vert() if ADJTYPE=2 then call horiz() if ADJTYPE=3 then call vert() if (ADJTYPE=2|ADJTYPE=3) then do OrgImage = AdjImage 'BRIGHTNESS' LoadImage '-255' 'INTENSITY' /* Black image */ AdjImage = Result end if ADJTYPE=2 then call vert() if ADJTYPE=3 then call horiz() if (ADJTYPE=2|ADJTYPE=3) then 'CLOSE' OrgImage 'CLOSE' LoadImage OutputImage = AdjImage if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ horiz: do X = 0 to (IW+SLICE_H) by SLICE_H BX = X ; BY = 0 ; BEX = (X+SLICE_H-1) ; BEY = (IH-1) if X >= IW then leave if (X+SLICE_H) > (IW-1) then BEX = (IW-1) 'CROP' OrgImage BX BY BEX BEY CropImage=RESULT 'MARK' CropImage 'PRIMARY' 'MARK' AdjImage 'SECONDARY' 'COMPOSITE' X (trunc(ADJ_H/2)*UoD) 'MIX 100' Out = RESULT ; 'CLOSE' AdjImage ; 'CLOSE' CropImage ; AdjImage = Out if UoD = 1 then UoD = -1 else UoD = 1 end return 'OK' vert: do Y = 0 to (IH+SLICE_V) by SLICE_V BX = 0 ; BY = Y ; BEX = (IW-1) ; BEY = (Y+SLICE_V-1) if Y >= IH then leave if (Y+SLICE_V) > (IH-1) then BEY = (IH-1) 'CROP' OrgImage BX BY BEX BEY CropImage=RESULT 'MARK' CropImage 'PRIMARY' 'MARK' AdjImage 'SECONDARY' 'COMPOSITE' (trunc(ADJ_V/2)*UoD) Y 'MIX 100' Out = RESULT ; 'CLOSE' AdjImage ; 'CLOSE' CropImage ; AdjImage = Out if UoD = 1 then UoD = -1 else UoD = 1 end return 'OK' /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'